package com.dqyt.khjc.controller;

import com.dqyt.khjc.bean.ResultMsg;
import com.dqyt.khjc.service.ManufacturerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/***
 * 制造厂商
 */
@RestController
public class ZzcsController {


    @Autowired
    private ManufacturerService manufacturerService;

    /**
     * 分页查询 制造厂商列表
     * @param request
     * @param page
     * @param size
     * @param name
     * @param enname
     * @return
     */
    @RequestMapping(value = "/api/getZzcsListPage", method = {RequestMethod.GET,RequestMethod.POST})
    public ResultMsg getZzcsListPage(HttpServletRequest request,
                                         @RequestParam(defaultValue = "1") Integer page,
                                         @RequestParam(defaultValue = "10") Integer size,
                                         @RequestParam(name = "name", required = false, defaultValue = "") String name,
                                         @RequestParam(name = "enname", required = false, defaultValue = "") String enname
    ){
        ResultMsg resultMsg = manufacturerService.getZzcsListPage(request,page,size,name,enname);
        return resultMsg;
    }





    @RequestMapping(value = "/api/addZzcs", method = {RequestMethod.POST})
    public  ResultMsg addZzcs(HttpServletRequest request,String name,String enname,String abridge){
        ResultMsg resultMsg = manufacturerService.addZzcs(request,name,enname,abridge);
        return resultMsg;
    }


    @RequestMapping(value = "/api/delZzcs", method = {RequestMethod.POST})
    public  ResultMsg delZzcs(HttpServletRequest request,long id){
        ResultMsg resultMsg = manufacturerService.delZzcs(request,id);
        return resultMsg;
    }

    /**
     * 修改
     * @param request
     * @param id
     * @param name
     * @param enname
     * @return
     */
    @RequestMapping(value = "/api/updateZzcs", method = {RequestMethod.POST})
    public  ResultMsg updateZzcs(HttpServletRequest request,long id,String name,String enname,String abridge){
        ResultMsg resultMsg = manufacturerService.updateZzcs(request,id,name,enname,abridge);
        return resultMsg;
    }




}
